var pomelo = require('pomelo');
var async = require('async');
var wt = require('async').waterfall;
var each = require('async').each;

var http = require('http');
var url = require("url");


var connectorService = require('../services/connectorService');


var log = console.log;

module.exports = function (app, opts) {
    return new httpServer(app, opts);
};

var DEFAULT_INTERVAL = 3000;

var httpServer = function (app, opts) {
    this.app = app;
    this.opts = opts;
    // this.interval = opts.interval || DEFAULT_INTERVAL;
    this.timerId = null;
};

httpServer.name = '__httpServer__';

httpServer.prototype.start = function (cb) {
    console.log('httpServer Start');
    process.nextTick(cb);
};

httpServer.prototype.afterStart = function (cb) {
    var self = this;
    console.log('httpServer afterStart');
    // clearInterval(this.timerId);

    // log(this.app.get('sessionService'));

    this.app.set('connectorService', new connectorService(self.app, self.opts));
    process.nextTick(cb);
};

httpServer.prototype.stop = function (force, cb) {
    console.log('httpServer stop');
    process.nextTick(cb);
};
